
import React, { Component } from 'react';
import { Router, Route, hashHistory, IndexRedirect, browserHistory,IndexRoute } from 'react-router';
import App from '../App';
import Login from '../pages/login/login';
import Home from '../pages/Cms/home'
import HomeTwo from '../pages/Cms/list/two'
import ChangePassWord from '../pages/login/changePassword'
import List from '../pages/Cms/home/list'
import Add from '../pages/Cms/home/add'
export default class CRouter extends Component {
    constructor(props){
        super(props)
        this.state={
            token:""
        }
    }
    componentWillMount() {
        // let BrowserUrl=window.location.href
        let BrowserUrl="http://qa.pms.shangpin.com/?token=06490c69-202b-4888-bd32-75364a946a74"

        this.setState({
            token:BrowserUrl.split("?").pop().split("=").pop()
        })
        // if(this.state.token===""){
        //     window.location.href="http://qa.uaas.shangpin.com/login.html?client_url=http://qa.pms.shangpin.com"
        // }else {
        //     browserHistory.push('/app/home')
        // }
    }

    render() {
        console.log(window.location.href)
        return (

            <Router history={browserHistory}>

                <Route path={'/'}>
                    <IndexRedirect to="app/home/list"/>
                    <Route path={'app'} component={App}>
                        <Route exact path='home' component={Home}>
                            <IndexRedirect to="list"/>
                            <Route exact path='list' component={List}></Route>
                            <Route exact path='add' component={Add}></Route>
                        </Route>
                        <Route exact path='changePassWord' component={ChangePassWord}></Route>
                    </Route>
                </Route>
            </Router>
        )
    }
}